using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using System;
namespace Salient.SharpZipLib.Zip
{
	public class IsolatedZipEntryFactory : IEntryFactory
	{
		public enum TimeSetting
		{
			LastWriteTime,
			LastWriteTimeUtc,
			CreateTime,
			CreateTimeUtc,
			LastAccessTime,
			LastAccessTimeUtc,
			Fixed
		}
		private INameTransform nameTransform_;
		private DateTime fixedDateTime_ = DateTime.get_Now();
		private IsolatedZipEntryFactory.TimeSetting timeSetting_;
		private bool isUnicodeText_;
		private int getAttributes_ = -1;
		private int setAttributes_;
		public INameTransform NameTransform
		{
			get
			{
				return this.nameTransform_;
			}
			set
			{
				if (value == null)
				{
					this.nameTransform_ = new ZipNameTransform();
				}
				else
				{
					this.nameTransform_ = value;
				}
			}
		}
		public IsolatedZipEntryFactory.TimeSetting Setting
		{
			get
			{
				return this.timeSetting_;
			}
			set
			{
				this.timeSetting_ = value;
			}
		}
		public DateTime FixedDateTime
		{
			get
			{
				return this.fixedDateTime_;
			}
			set
			{
				if (value.get_Year() < 1970)
				{
					throw new ArgumentException("Value is too old to be valid", "value");
				}
				this.fixedDateTime_ = value;
			}
		}
		public int GetAttributes
		{
			get
			{
				return this.getAttributes_;
			}
			set
			{
				this.getAttributes_ = value;
			}
		}
		public int SetAttributes
		{
			get
			{
				return this.setAttributes_;
			}
			set
			{
				this.setAttributes_ = value;
			}
		}
		public bool IsUnicodeText
		{
			get
			{
				return this.isUnicodeText_;
			}
			set
			{
				this.isUnicodeText_ = value;
			}
		}
		public IsolatedZipEntryFactory()
		{
			this.nameTransform_ = new ZipNameTransform();
		}
		public IsolatedZipEntryFactory(IsolatedZipEntryFactory.TimeSetting timeSetting)
		{
			this.timeSetting_ = timeSetting;
			this.nameTransform_ = new ZipNameTransform();
		}
		public IsolatedZipEntryFactory(DateTime time)
		{
			this.timeSetting_ = IsolatedZipEntryFactory.TimeSetting.Fixed;
			this.FixedDateTime = time;
			this.nameTransform_ = new ZipNameTransform();
		}
		public ZipEntry MakeFileEntry(string fileName)
		{
			return this.MakeFileEntry(fileName, true);
		}
		public ZipEntry MakeFileEntry(string fileName, bool ignored)
		{
			ZipEntry zipEntry = new ZipEntry(this.nameTransform_.TransformFile(fileName));
			zipEntry.IsUnicodeText = this.isUnicodeText_;
			if (this.timeSetting_ == IsolatedZipEntryFactory.TimeSetting.Fixed)
			{
				zipEntry.DateTime = this.fixedDateTime_;
			}
			if (this.setAttributes_ != 0)
			{
				zipEntry.ExternalFileAttributes = this.setAttributes_;
			}
			return zipEntry;
		}
		public ZipEntry MakeDirectoryEntry(string directoryName)
		{
			return this.MakeDirectoryEntry(directoryName, true);
		}
		public ZipEntry MakeDirectoryEntry(string directoryName, bool ignored)
		{
			ZipEntry zipEntry = new ZipEntry(this.nameTransform_.TransformDirectory(directoryName))
			{
				IsUnicodeText = this.isUnicodeText_,
				Size = 0L
			};
			if (this.timeSetting_ == IsolatedZipEntryFactory.TimeSetting.Fixed)
			{
				zipEntry.DateTime = this.fixedDateTime_;
			}
			int externalFileAttributes = this.setAttributes_ | 16;
			zipEntry.ExternalFileAttributes = externalFileAttributes;
			return zipEntry;
		}
	}
}
